<?php


namespace app\api\controller;

use app\api\model\Banner;
use app\api\model\Matchmaker;
use app\api\model\Users;
use app\api\model\Visitor;
use app\common\controller\Api;
use app\common\model\Users as UsersModel;
use app\api\model\Collect;
class Vip extends Api
{
    protected $noNeedLogin = ['list', 'mobilelogin', 'register', 'resetpwd', 'changeemail', 'changemobile', 'third','my','mycollect','mydynamic','mytopic'];
     /**
      * 会员页
      *
      */
     public function list()
     {

         $uid = 1;
         $model = new Users();
        //获取登录用户id 拿到性别  如果为男 只推荐女    反之  只推荐男
        $userlist = $model->userlist($uid);
        return $userlist;
     }

    /**
     * 轮播图
     *
     */
    public function banner()
    {
        $rs=Banner::limit(2)->select();
        return $rs;
    }

    /**
     * 会员编号搜索
     *
     */

    public function searchnumber(){
        $data = input();
        $key = 1;
        $rs=UsersModel::where('number','like',"%{$key}%")->find();
        return json($rs);
    }

    /**
     * 更多情况，所有可选信息
     *
     */
    public function information()
    {

    }
    /**
     * 会员具体信息搜索
     *
     */
    public function vipinfo()
    {
        $data = input();

    }

    /**
     *
     * 看过我的
     */
    public function seeme()
    {
        //获取到当前登录用户
        $uid = 1;
        //如果不是会员不能看
        $res = UsersModel::where('id',$uid)->field('users_group_id')->find();
        if($res['users_group_id'] == 0)
        {
            return $this->error('非会员暂无权限查询','',0);
        }
      $list =  Visitor::where('fuid',$uid)->field('uid')->select();
        foreach ($list as $value){
            //根据遍历出的访问者id去用户表查询
          $userinfo =   UsersModel::where('id',$value['uid'])->find();
        }
        return $userinfo;
    }

    /**
     *
     * 收藏我的
     */
    public function collectme()
    {
        //获取到当前登录用户
        $uid = 1;
        //如果不是会员不能看
        $res = UsersModel::where('id',$uid)->field('users_group_id')->find();
        if($res['users_group_id'] == 0)
        {
            return $this->error('非会员暂无权限查询','',0);
        }
        $list =  Collect::where('becollect_id',$uid)->field('collect_id')->select();
        foreach ($list as $value){
            //根据遍历出的收藏者id去用户表查询
            $userinfo =   UsersModel::where('id',$value['collect_id'])->find();
        }
        return $userinfo;
    }

    /**
     * vip信息
     *
     */
    public function vipdetail()
    {
        //获取到当前登录用户
        $uid = 1;
        $res = UsersModel::where('id',$uid)->field('avatar,number,endtime')->find();
        return $res;
    }

    /**
     * 咨询红娘
     *
     */
    public function servicered()
    {
        //获取到当前登录用户
        $uid = 1;
        $res = UsersModel::with('matchmaker')->where('id',$uid)->field('matchmaker_id')->find();
        return $res;
    }

    /**
     * 实名认证
     */
   public function vipreal()
   {

   }
}